home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Examples / Draw / Sources / DrawClip.cpp < prev    next >
Encoding:
Text File  |  1995-11-08  |  3.7 KB  |  147 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                DrawClip.cpp
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Author:                Henri Lamiraux
  7. //
  8. //    Copyright:    © 1993, 1995 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #include "ODFDraw.hpp"
  13.  
  14. #ifndef DRAWCLIP_H
  15. #include "DrawClip.h"
  16. #endif
  17.  
  18. #ifndef DRAWPART_H
  19. #include "DrawPart.h"
  20. #endif
  21.  
  22. #ifndef BASESHP_H
  23. #include "BaseShp.h"
  24. #endif
  25.  
  26. #ifndef BOUNDSHP_H
  27. #include "BoundShp.h"
  28. #endif
  29.  
  30. #ifndef LINESHP_H
  31. #include "LineShp.h"
  32. #endif
  33.  
  34. #ifndef OVALSHP_H
  35. #include "OvalShp.h"
  36. #endif
  37.  
  38. #ifndef RECTSHP_H
  39. #include "RectShp.h"
  40. #endif
  41.  
  42. #ifndef RRECTSHP_H
  43. #include "RRectShp.h"
  44. #endif
  45.  
  46. #ifndef TEXTSHP_H
  47. #include "TextShp.h"
  48. #endif
  49.  
  50. #ifndef DRAWFRM_H
  51. #include "DrawFrm.h"
  52. #endif
  53.  
  54. #ifndef DRAWPRXY_H
  55. #include "DrawPrxy.h"
  56. #endif
  57.  
  58. // ----- Part Includes -----
  59.  
  60. #ifndef FWUTIL_H
  61. #include "FWUtil.h"
  62. #endif
  63.  
  64. // ----- OS Includes -----
  65.  
  66. #ifndef FWODGEOM_H
  67. #include "FWODGeom.h"
  68. #endif
  69.  
  70. // ----- OpenDoc Includes -----
  71.  
  72. #ifndef SOM_ODShape_xh
  73. #include <Shape.xh>
  74. #endif
  75.  
  76. //========================================================================================
  77. // RunTime Info
  78. //========================================================================================
  79.  
  80. #ifdef FW_BUILD_MAC
  81. #pragma segment odfdraw
  82. #endif
  83.  
  84. //========================================================================================
  85. //    class CDrawFacetClipper
  86. //========================================================================================
  87.  
  88. //---------------------------------------------------------------------------------------
  89. //    CDrawFacetClipper::CDrawFacetClipper
  90. //---------------------------------------------------------------------------------------
  91.  
  92. CDrawFacetClipper::CDrawFacetClipper(Environment *ev, CDrawPart* part):
  93.     FW_CFacetClipper(ev, part),
  94.     fDrawPart(part)
  95. {
  96. }
  97.  
  98. //---------------------------------------------------------------------------------------
  99. //    CDrawFacetClipper::~CDrawFacetClipper
  100. //---------------------------------------------------------------------------------------
  101.  
  102. CDrawFacetClipper::~CDrawFacetClipper()
  103. {
  104. }
  105.  
  106. //----------------------------------------------------------------------------------------
  107. // CDrawFacetClipper::ClipEmbeddedFacets
  108. //----------------------------------------------------------------------------------------
  109.  
  110. void CDrawFacetClipper::ClipEmbeddedFacets(Environment *ev, 
  111.                                             FW_CEmbeddingFrame* embeddingFrame, 
  112.                                             ODFacet* containingFacet, 
  113.                                             ODShape* limitShape)
  114. {
  115.     // ----- If no proxy shape we don't have anything to do -----
  116.     if (CProxyShape::gProxyCount == 0)
  117.         return;
  118.     
  119.     FW_CPoint extent;
  120.     embeddingFrame->GetContentExtent(ev, extent);
  121.  
  122.     FW_CRect limitRect;
  123.     if (limitShape)
  124.         limitRect = FW_GetShapeBoundingBox(ev, limitShape);
  125.     else
  126.         limitRect.Set(FW_kZeroPoint, extent.x, extent.y);
  127.     
  128.     // ----- Create a temporary shape -----
  129.     FW_CAcquiredODShape aqTempShape = ::FW_NewODShape(ev);
  130.     
  131.     // ----- Create the working clip (use the content shape) -----
  132.     FW_CAcquiredODShape aqWorkingClip = embeddingFrame->AcquireContentShape(ev);    // in Frame Coordinate
  133.  
  134.     FW_CAcquiredODTransform aqWindowContentTransform(containingFacet->AcquireWindowFrameTransform(ev, NULL));
  135.     aqWorkingClip->Transform(ev, aqWindowContentTransform);        // now in window coordinate
  136.     
  137.     // ----- Go through my shapes (backward) ------
  138.     FW_COrderedCollectionIterator ite(fDrawPart->GetShapeList());
  139.     for (CBaseShape* shape = (CBaseShape*)ite.Last(); ite.IsNotComplete(); shape = (CBaseShape*)ite.Previous())
  140.     {
  141.         FW_CRect dragRect;
  142.         shape->GetDragRect(dragRect);
  143.         if (limitRect.IsIntersecting(dragRect))
  144.             shape->SubtractToWindowClip(ev, this, containingFacet, aqWorkingClip, aqTempShape);
  145.     }
  146. }
  147.